//
//  CellForAVNews.m
//  MY Project For Sport
//
//  Created by dllo on 16/3/2.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForAVNews.h"
#import "ModelForAV.h"
#import <SDWebImage/UIImageView+WebCache.h>

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface CellForAVNews ()

@property (nonatomic, retain)UIImageView *image;
@property (nonatomic, retain)UILabel *labelForsum;

@end

@implementation CellForAVNews

- (void)dealloc {
    [_image release];
    [_labelForsum release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
      
        [self createSubview];
        
    }

    return self ;

}

- (void)createSubview {

    self.image = [[UIImageView alloc] init];
    [self.contentView addSubview:self.image];
    [_image release];
    
    self.labelForsum = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForsum];
    [_labelForsum release];

}

- (void)layoutSubviews {

    [super layoutSubviews];


    self.image.frame = CGRectMake(5 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width / 4, self.contentView.frame.size.height - 10 * HEIGHTT);
   // self.image.backgroundColor = [UIColor redColor];

    
    self.labelForsum.textColor = [UIColor grayColor];
    self.labelForsum.numberOfLines = 0;
    self.labelForsum.frame = CGRectMake(self.contentView.frame.size.width / 4 + 10 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width - self.contentView.frame.size.width / 4 - 15 * WEIGHTT, self.contentView.frame.size.height - 25 * HEIGHTT);
    //self.labelForsum.backgroundColor = [UIColor orangeColor];
    
}

- (void)passModelForAv:(ModelForAV *)model {

    [self.image sd_setImageWithURL:[NSURL URLWithString:model.imagelink]];
    self.labelForsum.text = model.title;

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
